<template>
    <div>
        <ul class="switches">
            <li class="switch-item" v-for="(item,index) in switches"
                :class="{'active':currentIndex===index}"
                @click="switchItem(index)"
            >
              <span>{{item.name}}</span>
            </li>
        </ul>
        <div class="content">
            <slot></slot>
        </div>
    </div>
    
</template>

<script type="text/ecmascript-6">
export default {
  props: {
    switches: {
      type: Array,
      default: []
    },
    currentIndex: {
      type: Number,
      default: 0
    }
  },
  methods: {
    switchItem(index) {
      this.$emit("switch", index);
    }
  }
};
</script>

<style scoped lang="stylus" rel="stylesheet/stylus">
@import '~common/stylus/variable';

.switches {
    display: flex;
    align-items: center;

    .switch-item {
        width: 80px;
        text-align: center;
        font-size: $font-size-medium;
        color: $color-text
        padding: 5px 10px;
        border-bottom 2px solid $color-background-d

        &.active {
            color: $color-theme;
            border-bottom 2px solid $color-theme
        }
    }
}

.content {
    text-align: left;
    box-sizing: border-box;
    padding: 10px 15px;
}
</style>
